package dl.bukkit.myststus.function.trigger.imp;

import dl.bukkit.myststus.MyStatus;
import dl.bukkit.myststus.api.event.ReloadEvent;
import dl.bukkit.myststus.configuration.imp.Config;
import dl.bukkit.myststus.function.trigger.TriggerHud;
import dl.bukkit.myststus.library.ats.GComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;

import java.util.ArrayList;

@GComponent(
        key = "reload",
        author = "dogLong"
)
public class ReloadTrigger extends TriggerHud<ReloadEvent> {
    @Override
    public boolean isRemove(ReloadEvent event) {
        return false;
    }

    @Override
    public Class<ReloadEvent> getEvent() {
        return ReloadEvent.class;
    }

    @Override
    public void trigger(ReloadEvent event) {
        MyStatus.runTaskAsynchronously(() -> {
            for (Player player : new ArrayList<>(Bukkit.getOnlinePlayers())) {
                getList().forEach(hud -> {
                    hud.sendHud(player, player);
                });
            }
        });
    }

    @Override
    public void send(ReloadEvent event) {

    }

    @Override
    public void remove(ReloadEvent event) {

    }

    @Override
    public Player getPlayer(ReloadEvent event) {
        return null;
    }

    @Override
    public Entity getTarget(ReloadEvent event) {
        return null;
    }

    @Override
    public boolean isRegister() {
        return Config.getInst().getBoolean("Trigger.Reload");
    }
}
